import java.util.Scanner;

/**
 * @author ShenTuZhiGang
 * @version 1.0.0
 * @email 1600337300@qq.com
 * @date 2021-09-18 18:03
 */
public class ExamNetEase2021091804_2_TIMEOUT {
    private static int n;
    private static int a;
    private static int b;
    private static int[][] ans;
    private static boolean flag = false;
    private static int[][] pos = new int[2][2];
    private static char[][] map;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        a = scanner.nextInt();
        b = scanner.nextInt();
        map = new char[n][n];
        ans = new int[n][n];
        pos[0][0] = -1;
        pos[0][1] = -1;
        pos[1][0] = -1;
        pos[1][1] = -1;
        int p = 0;
        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            map[i] = scanner.nextLine().toCharArray();
            for (int j = 0; j < n; j++) {
                if (map[i][j] == '*') {
                    pos[p][0] = i;
                    pos[p][1] = j;
                    flag = true;
                }
                ans[i][j] = Integer.MAX_VALUE;
            }
        }
        dfs(0, 0, 0);
        System.out.println(ans[n - 1][n - 1]);
    }

    public static void dfs(int x, int y, int count) {
        if (x >= n || y >= n || x < 0 || y < 0 || count > ans[n - 1][n - 1]) {
            return;
        }
        if (ans[x][y] > count) {
            ans[x][y] = count;
        } else {
            return;
        }
        int c1 = 0;
        if (map[x][y] == '#') {
            c1 = a;
        } else if (map[x][y] == '*') {
            if (x == pos[0][0] && y == pos[0][1]) {
                dfs(pos[1][0], pos[1][1], count + b);
            } else {
                dfs(pos[0][0], pos[0][1], count + b);
            }
        }
        dfs(x + 1, y, count + c1);
        dfs(x, y + 1, count + c1);
        dfs(x - 1, y, count + c1);
        dfs(x, y - 1, count + c1);
    }
}